package com.yunshipei.core.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.yunshipei.core.R;

public class DocPreviewDialog extends Dialog {

    private TextView cancleButton;

    public DocPreviewDialog(@NonNull Context context) {
        this(context, R.style.dialog_doc_preview);
    }

    public DocPreviewDialog(@NonNull Context context, @StyleRes int themeResId) {
        super(context, themeResId);
        View contentView = LayoutInflater.from(context).inflate(R.layout.dialog_doc_preview, null);
        setContentView(contentView);
        cancleButton = (TextView) contentView.findViewById(R.id.btn_cancel_preview);
        setCancelable(false);
        setOnKeyListener(new DialogInterface.OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                return keyCode == KeyEvent.KEYCODE_BACK;
            }
        });
    }

    protected DocPreviewDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public void setOnCancelPreviewListener(View.OnClickListener clickListener) {
        cancleButton.setOnClickListener(clickListener);
    }
}
